
<!DOCTYPE html>
<html lang="zh-cn">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="renderer" content="webkit">
		<title>登录</title>
		<link rel="stylesheet" href="http://www.pintuer.com/css/pintuer.css">
		<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.9.1/jquery.min.js"></script>
		<script src="http://www.pintuer.com/js/pintuer.js"></script>
	</head>

	<body>
		<div class="container">
			<div class="line">
				<div id="login_panel" class="xs6 xm4 xs3-move xm4-move">
					<br />
					<br />
					<br />
					<br />
					<form method="post">
						<div class="panel">
							<div class="panel-head"><strong>superms登录测试</strong></div>
							<div class="panel-body" style="padding:30px;">
								<div class="form-group">
									<div class="field field-icon-right">
										<input type="text" class="input" id="loginName" name="loginName" placeholder="登录账号" value="admin" data-validate="required:请填写账号,length#>=5:账号长度不符合要求" />
										<span class="icon icon-user"></span>
									</div>
								</div>
								<div class="form-group">
									<div class="field field-icon-right">
										<input type="password" class="input" id="password" name="password" placeholder="登录密码" value="123456" data-validate="required:请填写密码,length#>=6:密码长度不符合要求" />
										<span class="icon icon-key"></span>
									</div>
								</div>
							</div>
							<div class="panel-foot text-center">
								<input type="button" class="button button-block bg-main text-big J_login_btn" value="登录" />
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>

<script> 

var accessToken; 
$(document).ready(function() {

    $(".J_login_btn").click(function() {
        
    	var params = {};
		var dataArrays = $('form').serializeArray();
		if(dataArrays){
			$.each( dataArrays, function(i, field){
				if(field.value && field.value != ''){					
					params[field.name] = field.value;
				}
			});
		}
		
        $.ajax({
            url: '/api/login',
            type: "post",
            async: false,
            cache: false,
            dataType: "json",
            contentType: "application/json",
	        data:JSON.stringify(params) ,
            success: function(json) {
               if(json.code == 200){
               	 alert("登录成功");
               	 setTimeout(function(){window.location.href = './index.html';},500);
               }else{
                  alert(json.msg);
               }
            },
            error: function() {
                alert('Error');
            }
        });
    });

});  
</script>  

</body>

</html>